<template>
  <a-card :bordered="false">
    <component @onEdit="handleEdit" @onGoBack="handleGoBack" :record="record" :is="currentComponet"/>
  </a-card>
</template>

<script>

  import ATextarea from 'ant-design-vue/es/input/TextArea'
  import AInput from 'ant-design-vue/es/input/Input'
  // 动态切换组件
  import List from '@/perm/views/permission/PermissionList'
  import Edit from '@/perm/views/permission/PermissionEdit'

  export default {
    name: 'TableListWrapper',
    components: {
      AInput,
      ATextarea,
      List,
      Edit
    },
    data () {
      return {
        currentComponet: 'List',
        record: ''
      }
    },
    created () {

    },
    methods: {
      handleEdit (record) {
        this.record = record || ''
        this.currentComponet = 'Edit'
        console.log(record)
      },
      handleGoBack () {
        this.record = ''
        this.currentComponet = 'List'
      }
    },
    watch: {
      '$route.path' () {
        this.record = ''
        this.currentComponet = 'List'
      }
    }
  }
</script>
